package com.sugon.springboot.controller;

import com.mysql.jdbc.log.Log;
import com.sugon.springboot.entities.CommonResult;
import com.sugon.springboot.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@Slf4j
public class OrderController {
    public static String payment_url = "http://localhost:8001";
    @Resource
    RestTemplate restTemplate;

    @PostMapping("consumer/payment/create")
    public CommonResult<Payment> create(Payment payment){
        return restTemplate.postForObject(payment_url+"/payment/create",payment,CommonResult.class);
    }

    @GetMapping("consumer/payment/get/{id}")
    public CommonResult<Payment> select(@PathVariable("id") Long id){
        return restTemplate.getForObject(payment_url+"/payment/get/"+id,CommonResult.class);
    }

}
